from PIL import Image

img = Image.open("F:/temp_file/geetest/nine_slice/sample_a.png")
# 每个小图片的长（或宽）: 112
cell_len = 112
# 小图片直接的黑边间隔: 4
mar_len = 4
for h in range(3):
    up = (cell_len + mar_len) * h
    for w in range(3):
        cropped = img.crop(((cell_len + mar_len) * w, up, cell_len * (w + 1) + mar_len * w, cell_len + up))
        cropped.save("F:/temp_file/geetest/nine_slice/sample_a_" + str(h) + "_" + str(w) + ".png")

print('finished!')


